﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using CoreEx.Database.Metadata;

namespace CoreEx.Database.MetaData.Implementation
{
    public class PropertyMappingInfo : IPropertyMappingInfo
    {
        public PropertyMappingInfo()
        {
            RelationType = CardinalityType.None;
        }

        public PropertyInfo Property { get; set; }
        public IColumnInfo ColumnInfo { get; set; }
        public IForeignKeyInfo ForeignKeyInfo { get; set; }        
        public CardinalityType RelationType { get; set;}

        public override string ToString()
        {
            switch (RelationType)
            {
                case CardinalityType.None:
                    return string.Format("{0} => {1}",Property.Name, ColumnInfo.ColumnName);
                case CardinalityType.OneToOne:
                case CardinalityType.ManyToOne:
                case CardinalityType.ManyToMany:
                case CardinalityType.OneToMany:
                    return string.Format("{0} => {1}", Property.Name, ForeignKeyInfo.Name);
            }
            return base.ToString();
        }
    }
}
